function [ref, label] = refstat(stat)
% Returns reference statistic of melody and associated labels specified by STAT
% [ref, label] = refstat(stat)
% REFSTAT function returns a selected reference statistic of melody (STAT):
%
% Input arguments: STAT= any of the following strings:
%        kkmaj = Krumhansl & Kessler (1982) major key profile (tonality)
%        kkmin =  Krumhansl & Kessler (1982) minor key profile (tonality)
%        kkmajt =  Krumhansl & Kessler (1982) major key profile modified by Temperley (1999)
%        kkmint =  Krumhansl & Kessler (1982) minor key profile modified by Temperley (1999)
%        kkmaj_as =  Krumhansl & Kessler (1982) major key profile modified by Albrecht and Shanahan (2013)
%        kkmin_as =  Krumhansl & Kessler (1982) minor key profile modified by Albrecht and Shanahan (2013)
%        pc_all = Pitch-Classes in the Essen Collection (ALL songs,  incl. Asian) by Schaffrath (1995)
%        pc_europe_maj = Pitch-classes in Essen Collection (Major songs, not incl. Asian)
%        pc_europe_min = Pitch-classes in Essen Collection (Minor songs, not incl. Asian)
%        iv_all = Intervals from Essen folksong collection
%        ivnd_europe = Intervals (no direction) from Essen col., not incl. Asian)
%        ivudr_europe = Intervals (up, down, repeat) Essen col., not incl. Asian)
%        iv_europe_maj = Interval transitions (Essen col., Major, Non-Asian)
%        ivdia_europe = Interval transitions, diatonic only (Essen col., not incl. Asian)
%        ivdiand_europe = Interval transitions, diatonic only, no direction (Essen col., not incl. Asian)
%        iv2 = Interval transitions (From Essen folksong collection)  (VECTOR)
%        twotone = Pitch-class transitions in Essen Collection (VECTOR)
%        pcdist1essen = Pitch-classen in Essen Collection (All songs, not incl. Asian, N=6231)
%        ivdist1essen = Intervals from Essen folksong collection (not incl. Asian)
%        durdist1essen = Duration distribution (From Essen folksong collection)
%        ivdist2essen = Interval transitions (From Essen folksong collection) (MATRIX)
%        pcdist2essen = Pitch-class transitions (From Essen folksong collection) (MATRIX)
%        durdist2essen = Duration transitions (From Essen folksong collection) (MATRIX)
%        pcdist2classical1 = Tone-transition probabilities from 16000 + classical music themes (Simonton, 1984)
%        pcdist2classical2 = Frequency of occurrence of melodic intervals by Youngblood (1958)
%        pcdist1schubert = Pitch-class distribution in Schubert pieces (Major key, Knopoff & Hutchinson (1983)
%
% Output: REF = probability vector for each component in the statistic. For example, major key profile is:
%	ref=[6.35,2.23,3.48,2.33,4.38,4.09,2.52,5.19,2.39,3.66,2.29,2.88];
%      LABEL = label for each statistic. As above this, would output:
%	 'C','C#','D','D#','E','F','F#','G','G#','A','A#','B'
%
% References:  
% Albrecht, J., & Shanahan, D. (2013). The Use of Large Corpora to 
%     Train a New Type of Key-Finding Algorithm. Music Perception: An 
%     Interdisciplinary Journal, 31(1), 59-67.	
% Knopoff, L. & Hutchinson, W. (1983). Entropy as a measure of style: 
%       The influence of sample length. Journal of Music Theory, 27, 75-97.
% Krumhansl, C. L., & Kessler, E. J. (1982). Tracing the dynamic changes 
%        in perceived tonal organization in a spatial representation of musical 
%        keys. Psychological Review, 89, 334-368.
% Schaffrath, H. (1995). The Essen Folksong Collection in Kern Format. 
%        [computer database] D. Huron (Ed.). Menlo Park, CA: Center for 
%        Computer Assisted Research in the Humanities.
% Simonton, D. K. (1984). Melodic structure and note transition probabilities: 
%        A content analysis of 15,618 classical themes. Psychology of 
%        Music, 12, 3-16.
% Temperley, D. (1999). What's Key for Key? The Krumhansl-Schmuckler 
%        key-finding algorithm reconsidered. Music Perception, 17, 65-100.
% Youngblood, J.E. (1958). Style as information. Journal of Music 
%       Theory, 2, 24-35.
%
% Example 1: Get major key profile by Krumshansl & Kessler (1982):
%   major = refstat('kkmaj');
%
% Example 2: Get interval transition probabilities in the Essen collection and the
% respective labels for all interval transitions:
%   [inttrans,label] = refstat('ivdist2essen');
%
% Authors:
%  Date		Time	Prog	Note
% 18.5.2016	17:21	TE	Created under MATLAB 2015b (Mac OSX)
% Part of the MIDI Toolbox, Copyright 2016, University of Jyvaskyla, Finland
% See License.txt

if ~ischar(stat),
   fprintf(1,'??? refstat: Argument must be a string.\n')
   return;
end;

switch lower(stat),

 case 'kkmaj'
	% Psychological data (K&K major profile)
	ref=[6.35,2.23,3.48,2.33,4.38,4.09,2.52,5.19,2.39,3.66,2.29,2.88];
	label = {'C','C#','D','D#','E','F','F#','G','G#','A','A#','B'};
	label=cellstr(label')';

 case 'kkmin'
	% Psychological data (K&K minor profile)
	ref=[6.33,2.68,3.52,5.38,2.6,3.53,2.54,4.75,3.98,2.69,3.34,3.17];
	label = {'C','C#','D','D#','E','F','F#','G','G#','A','A#','B'};
	label=cellstr(label')';

 case 'kkmajt'
	% Psychological data revised (Temperley major profile)
	% Temperley, D. (1999). What's Key for Key? The Krumhansl-Schmuckler Key-Finding 
	% Algorithm Reconsidered. Music Perception, 17, 65-100.
	ref=[5,2,3.5,2,4.5,4,2,4.5,2,3.5,1.5,4];
	label = {'C','C#','D','D#','E','F','F#','G','G#','A','A#','B'};
	label=cellstr(label')';

 case 'kkmint'
	% Psychological data revised (Temperley minor profile)
	% Temperley, D. (1999). What's Key for Key? The Krumhansl-Schmuckler Key-Finding 
	% Algorithm Reconsidered. Music Perception, 17, 65-100.
	ref=[5,2,3.5,4.5,2,4,2,4.5,3.5,2,1.5,4];
	label = {'C','C#','D','D#','E','F','F#','G','G#','A','A#','B'};
	label=cellstr(label')';

 case 'kkmaj_as'
    % key finding based on euclidean distances and key profiles from common period
    % Albrecht, J. & Shanahan, D. (2013). The use of large corpora to train a new type of key-finding algorithm: an improved treatment of the minor mode
    % Music Perception, 31(1), 59–67. 
    ref=[0.238, 0.006, 0.111, 0.006, 0.137, 0.094, 0.016, 0.214, 0.009, 0.080, 0.008, 0.081];    
	label = {'C','C#','D','D#','E','F','F#','G','G#','A','A#','B'};
	label=cellstr(label')';
    
  case 'kkmin_as'
    % key finding based on euclidean distances and key profiles from common period
    % Albrecht, J. & Shanahan, D. (2013). The use of large corpora to train a new type of key-finding algorithm: an improved treatment of the minor mode
    % Music Perception, 31(1), 59–67. 
    ref=[0.220, 0.006, 0.104, 0.123, 0.019, 0.103, 0.012, 0.214, 0.062, 0.022, 0.061, 0.052];    
	label = {'C','C#','D','D#','E','F','F#','G','G#','A','A#','B'};
	label=cellstr(label')';    
    
 case 'pc_all'
	% Essen Collection: ALL songs,  incl Asian
	ref= [0.187,0.001,0.168,0.016,0.169,0.081,0.003,0.212,0.004,0.111,0.007,0.042];
	label = {'C','C#','D','D#','E','F','F#','G','G#','A','A#','B'};
	label=cellstr(label')';

 case 'pcdist1essen'
	% Essen Collection: All songs, not incl. Asian (r with above, .98), N=6231
	ref= [0.187,0.001,0.168,0.016,0.169,0.081,0.003,0.212,0.004,0.111,0.007,0.042];
	label = {'C','C#','D','D#','E','F','F#','G','G#','A','A#','B'};
	label=cellstr(label')';

 case 'pc_europe_maj'
	% Essen Collection: Major songs, not incl. Asian (r with above, .98)
	ref = [0.196,0.001,0.156,0.004,0.179,0.107,0.005,0.214,0.001,0.076,0.003,0.058];
	label = {'C','C#','D','D#','E','F','F#','G','G#','A','A#','B'};
	label=cellstr(label')';

 case 'pc_europe_min'
	% Essen Collection: Minor songs, not incl. Asian 
	ref=[0.2193,0.0034,0.1475,0.1748,0.0015,0.1274,0.0019,0.2086,0.0307,0.0098,0.0548,0.0204];
	label = {'C','C#','D','D#','E','F','F#','G','G#','A','A#','B'};
	label=cellstr(label')';

 case 'ivdist1essen'
	ref=[0.0013;0.0000;0.0008;0.0019;0.0033;0.0093;0.0018;0.0191;0.0281;0.0608;
	0.2156;0.0878;0.2137;0.0654;0.1370;0.0500;0.0313;0.0455;0.0006;0.0119;0.0030;
	0.0073;0.0022;0.0001;0.0021]';
	label = {'DP8';'DM7';'Dm7';'DM6';'Dm6';'DP5';'Dd5';'DP4';'DM3';'Dm3';'DM2';'Dm2';'P1';'Um2';
	'UM2';'Um3';'UM3';'UP4';'Ud5';'UP5';'Um6';'UM6';'Um7';'UM7';'UP8'}';

 case 'iv2'
	ref=[0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;
	0.0003;0.0002;0;0;0;0.0005;0;0.0002;0;0;0.0005;0;0.0002;0;0;0;0;0;0;0;0;0;
	0.0002;0.0001;0.0045;0.0004;0.0068;0.0052;0.0015;0.0027;0.0007;0.0025;0.0004;
	0.0001;0.0003;0.0002;0.0007;0;0;0;0;0;0;0;0;0;0;0;0.0125;0.0009;0.0205;0.0101;
	0.0008;0.0229;0.0021;0.0149;0.0017;0;0.0010;0;0.0057;0;0;0;0;0;0;0;0;0.0001;0;
	0;0.0031;0;0.0172;0.0004;0.0148;0.0178;0.0034;0.0055;0;0.0399;0;0.0012;0.0029;
	0;0.0009;0;0;0;0;0;0.0001;0;0;0;0.0032;0.0012;0.0127;0.0882;0.0093;0.0871;0.0060;
	0.1080;0.0457;0.0064;0.0286;0.0003;0.0193;0.0008;0.0013;0;0;0;0;0;0;0;0;0;0;0;
	0.0004;0.0001;0.0110;0.0045;0.0075;0.0100;0.0004;0.0096;0.0011;0.0012;0.0020;
	0.0003;0.0025;0.0006;0.0024;0;0;0;0;0;0;0;0.0035;0;0.0037;0.0542;0.0034;0.1526;
	0.0032;0.1386;0.1249;0.0569;0.0707;0.0051;0.1316;0.0001;0.0157;0.0134;0.0017;
	0.0010;0;0;0;0;0.0004;0;0.0016;0.0002;0.0028;0.0017;0.0001;0.2147;0.0076;0.1654;
	0.1148;0.0036;0.2973;0.0008;0.0798;0.0082;0.0013;0.0052;0.0000;0.0480;0;0.0001;0;
	0;0;0;0.0014;0;0.0012;0.0007;0.0584;0.0362;0.0298;0.4439;0.0055;0.3895;0.2343;
	0.2663;0.2186;0.0001;0.1470;0.0007;0.0549;0.0180;0.0018;0.0100;0;0;0;0;0.0002;
	0.0012;0.0076;0.0026;0.0004;0.0551;0.0070;0.4932;1.5805;1.0857;1.2069;0.0118;
	0.9426;0.2981;0.3140;0.1924;0.0022;0.0905;0.0034;0.0851;0.0045;0.0004;0;0;0.0001;
	0;0.0018;0.0004;0.0057;0.0023;0.0013;0.0981;0.0073;1.0375;0.0069;0.4105;0.2978;
	0.0011;0.2021;0.0010;0.1526;0.0029;0.0049;0.0295;0.0001;0.0242;0;0;0;0.0001;
	0.0046;0.0120;0.0117;0.0917;0.0081;0.1506;0.1921;0.2845;1.2168;0.3516;1.9094;
	0.3219;0.6909;0.3851;0.1656;0.4094;0.0059;0.1635;0.0212;0.0770;0.0201;0.0002;
	0;0;0;0.0020;0.0002;0.0367;0.0011;0.0396;0.0188;0.0028;0.2418;0.0024;0.4758;
	0.2205;0.0128;0.6640;0.0026;0.0914;0.0032;0.0022;0.0107;0;0.0148;0;0.0004;0;0;
	0.0004;0.0022;0.0069;0.0032;0.0367;0.0003;0.0760;0.1808;0.1278;0.7393;0.0019;
	0.8238;0.6242;0.7585;0.1095;0.0018;0.1597;0.0003;0.0408;0.0069;0.0012;0.0025;
	0;0;0;0;0.0017;0.0036;0.0316;0.0090;0.0126;0.0407;0.0005;0.2903;0.1021;0.2815;
	0.3072;0.0100;0.1768;0.0191;0.2498;0.0133;0.0017;0.0112;0;0.0083;0;0;0;0;0.0000;
	0.0055;0.0043;0;0.0418;0.0018;0.0124;0.1138;0.0003;0.2112;0.0011;0.2742;0.1320;
	0.0057;0.0197;0.0001;0.1304;0;0.0029;0.0023;0;0.0001;0;0;0;0;0.0016;0.0290;0.0096;
	0.0550;0.0007;0.1462;0.0636;0.1022;0.2718;0.0619;0.6038;0.0138;0.0954;0.1281;
	0.0078;0.0085;0;0.0135;0.0004;0.0006;0;0;0;0;0;0;0.0001;0.0003;0.0001;0.0014;0.0001;
	0.0014;0.0013;0.0042;0.0049;0.0039;0.0013;0.0003;0.0025;0.0005;0;0;0;0;0;0;0;0;0;
	0.0004;0.0015;0.0019;0.0003;0.0306;0.0007;0.0160;0.0898;0.0209;0.1723;0.0024;
	0.1211;0.0264;0.0104;0.0063;0.0000;0.0112;0;0.0005;0.0001;0;0;0;0;0;0;0.0004;0;
	0.0018;0.0031;0.0002;0.0043;0.0005;0.0373;0.0083;0.0358;0.0262;0.0005;0.0111;0;
	0.0009;0;0;0.0002;0;0.0001;0;0;0;0;0;0.0028;0.0100;0;0.0251;0;0.0366;0.0304;0.0061;
	0.0433;0.0001;0.0881;0.0080;0.0057;0.0117;0;0.0019;0;0.0011;0;0;0;0;0;0;0;0.0022;
	0.0026;0.0000;0.0073;0.0004;0.0068;0.0033;0.0023;0.0131;0.0039;0.0306;0.0002;
	0.0003;0.0014;0.0002;0.0006;0;0;0;0;0;0;0;0;0;0;0;0;0.0002;0.0001;0;0.0007;0;
	0.0007;0.0003;0.0005;0.0001;0;0;0;0.0002;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;
	0;0;0;0;0;0;0;0;0;0;0;0;0;0]';

 case 'iv_all'
	% Essen Collection: ALL songs,  incl Asian (Notes=301380)
	ref=[0.0014;0.0000;0.0018;0.0025;0.0045;0.0116;0.0013;0.0302;0.0241;
	0.0811;0.2190;0.0637;0.1947;0.0458;0.1473;0.0674;0.0258;0.0492;0.0004;
	0.0127;0.0030;0.0061;0.0031;0.0001;0.0033]';
	label = {'DP8';'DM7';'Dm7';'DM6';'Dm6';'DP5';'Dd5';'DP4';'DM3';'Dm3';'DM2';'Dm2';'P1';'Um2';
	'UM2';'Um3';'UM3';'UP4';'Ud5';'UP5';'Um6';'UM6';'Um7';'UM7';'UP8'}';
	label=cellstr(label')';

 case 'iv_europe'
	% Essen Collection: ALL songs,  not incl Asian
	ref = [0.0013;0.0000;0.0008;0.0019;0.0033;0.0093;0.0018;0.0191;0.0281;
	0.0608;0.2156;0.0878;0.2137;0.0654;0.1370;0.0500;0.0313;0.0455;0.0006;
	0.0119;0.0030;0.0073;0.0022;0.0001;0.0021]';
	label = {'DP8';'DM7';'Dm7';'DM6';'Dm6';'DP5';'Dd5';'DP4';'DM3';'Dm3';'DM2';'Dm2';'P1';'Um2';
	'UM2';'Um3';'UM3';'UP4';'Ud5';'UP5';'Um6';'UM6';'Um7';'UM7';'UP8'}';
	label=cellstr(label')';

 case 'iv_europe_maj'
	% Essen Collection: Major songs,  not incl Asian
	ref = [0.002;0.000;0.001;0.002;0.004;0.010;0.002;0.020;0.029;0.061;0.221;
	0.079;0.217;0.058;0.136;0.048;0.034;0.048;0.001;0.012;0.003;0.008;0.003;
	0.000;0.002]';
	label = {'DP8';'DM7';'Dm7';'DM6';'Dm6';'DP5';'Dd5';'DP4';'DM3';'Dm3';'DM2';'Dm2';'P1';'Um2';
	'UM2';'Um3';'UM3';'UP4';'Ud5';'UP5';'Um6';'UM6';'Um7';'UM7';'UP8'}';
	label=cellstr(label')';

 case 'iv_europe_min'
	% Essen Collection: Major songs,  not incl Asian
	ref = [0.001;0.000;0.000;0.001;0.002;0.007;0.001;0.015;0.022;0.058;
	0.220;0.103;0.221;0.071;0.149;0.051;0.021;0.036;0.000;0.011;0.003;
	0.004;0.001;0.000;0.002];
	label = {'DP8';'DM7';'Dm7';'DM6';'Dm6';'DP5';'Dd5';'DP4';'DM3';'Dm3';'DM2';'Dm2';'P1';'Um2';
	'UM2';'Um3';'UM3';'UP4';'Ud5';'UP5';'Um6';'UM6';'Um7';'UM7';'UP8'}';
	label=cellstr(label')';

 case 'ivnd_europe'
	% Essen Collection: intervals, no direction (not incl Asian)
	ref=[0.196,0.105,0.369,0.149,0.050,0.080,0.002,0.024,0.008,0.009,0.005,0.000,0.003];
	label = {'P1','MI2','MA2','MI3','MA3','P4','D5','P5','MI6','MA6','MI7','MA7','P8'};
	label=cellstr(label')';

 case 'ivdia_europe'
	% Essen Collection: intervals, INTERVALS, DIATONIC ONLY (DIA) (not incl Asian)
	ref = [0.002;0.001;0.006;0.012;0.020;0.090;0.300;
	0.217;0.194;0.082;0.048;0.012;0.011;0.003;0.002]';
	label = {'-8','-7','-6','-5','-4','-3','-2','-1','2','3','4','5','6','7','8'};
	label=cellstr(label')';

 case 'ivdiand_europe'
	% Essen Collection: intervals, INTERVALS, DIATONIC ONLY (DIA), no direction (not incl Asian)
	ref = [0.217,0.450,0.172,0.067,0.024,0.017,0.004,0.004];
	label = {'1','2','3','4','5','6','7','8'};
	label=cellstr(label')';

 case 'ivudr_europe'
	% Essen Collection: intervals, Up, Down, Repeated (not incl Asian)
	ref = [0.353,0.430,0.217];
	label = {'up','down','level'};	label=cellstr(label')';

 case 'twotone'
ref = [0.0007;0;0.0003;0.0000;0.0002;0.0000;0;0.0013;0;0.0003;0.0000;0.0000;0.0000;
0;0;0;0;0.0000;0;0.0000;0;0;0;0;0.0000;0;0.0005;0;0.0002;0;0.0000;0.0012;0;0.0008;
0.0000;0.0001;0.0014;0;0.0003;0.0000;0;0.0002;0;0.0039;0.0000;0.0000;0.0001;0;0.0001;
0.0000;0.0000;0;0.0017;0;0.0000;0.0002;0.0000;0.0005;0;0.0003;0.0064;0;0.0016;0.0001;
0.0001;0.0003;0;0.0025;0.0000;0.0015;0.0000;0.0000;0.0000;0;0.0000;0.0000;0.0000;
0.0002;0.0000;0.0000;0;0.0000;0;0.0001;0.0026;0;0.0120;0.0001;0.0041;0.0001;0.0000;
0.0255;0.0000;0.0046;0.0006;0.0003;0.0190;0.0000;0.0001;0.0011;0.0000;0.0036;0;
0.0026;0.0001;0.0000;0.0002;0.0000;0.0022;0.0000;0.0068;0.0000;0.0318;0.0003;0.0003;
0.0013;0.0000;0.0162;0.0000;0.0045;0.0411;0.0001;0.0399;0.0047;0.0006;0.0185;0.0000;
0.0311;0.0004;0.0069;0.0018;0.0000;0.0002;0.0003;0.0053;0.0001;0.0208;0.0000;0.0021;
0.0016;0.0002;0.0010;0.0000;0.0169;0.0396;0.0001;0.0317;0.0029;0.0320;0.0143;0.0003;
0.0542;0.0004;0.0171;0.0014;0.0037;0.0207;0.0003;0.0002;0.0079;0.0001;0.0333;0.0001;
0.0017;0.0021;0.0002;0.0014;0.0000;0.0028;0.0000;0.0568;0.0002;0.0566;0.0058;0.0003;
0.0354;0.0000;0.0483;0.0008;0.0132;0.0223;0.0000;0.0054;0.0021;0.0001;0.0118;0.0000;
0.0338;0.0004;0.0003;0.0011;0.0001;0.0002;0.0000;0.0003;0.0000;0.0166;0.0000;0.0001;
0.0019;0.0000;0.0024;0;0.0028;0.0123;0;0.0044;0.0002;0.0006;0.0006;0;0.0080;0.0000;
0.0027;0.0001;0.0000;0.0001;0;0.0000;0;0;0.0010;0.0000;0.0000;0.0000;0.0000;0.0000;
0.0002;0.0003;0;0.0036;0;0.0014;0.0001;0.0000;0.0049;0;0.0009;0.0001;0.0001;0.0027;
0;0.0000;0.0000;0.0000;0.0002;0;0.0010;0.0000;0.0000;0.0000;0;0.0000;0;0.0002;0.0000;
0.0016;0;0;0.0000;0;0.0004;0;0.0001;0.0001;0;0.0002;0;0.0000;0.0003;0;0.0008;0;0.0001;
0.0000;0;0;0;0;0;0.0000;0;0;0;0;0;0;0.0000;0.0003;0;0.0001;0.0000;0.0001;0.0000;0;0.0006;
0;0.0001;0.0000;0.0000]';

label = {'c_cc';'d-_dd-';'d_dd';'e-_ee-';'e_ee';'f_ff';'g-_gg-';'g_gg';'a-_aa-';'a_aa';'b-_bb-';
'b_bb';'c_b';'d-_cc';'d_dd-';'e-_dd';'e_ee-';'f_ee';'g-_ff';'g_gg-';'a-_gg';'a_aa-';'b-_aa';'b_bb-';
'c_b-';'d-_b';'d_cc';'e-_dd-';'e_dd';'f_ee-';'g-_ee';'g_ff';'a-_gg-';'a_gg';'b-_aa-';'b_aa';'c_a';
'd-_b-';'d_b';'e-_cc';'e_dd-';'f_dd';'g-_ee-';'g_ee';'a-_ff';'a_gg-';'b-_gg';'b_aa-';'c_g-';'d-_a';
'd_b-';'e-_b';'e_cc';'f_dd-';'g-_dd';'g_ee-';'a-_ee';'a_ff';'b-_gg-';'b_gg';'c_g';'d-_g-';'d_a';
'e-_b-';'e_b';'f_cc';'g-_dd-';'g_dd';'a-_ee-';'a_ee';'b-_ff';'b_gg-';'c_g-';'d-_g';'d_g-';'e-_a';
'e_b-';'f_b';'g-_cc';'g_dd-';'a-_dd';'a_ee-';'b-_ee';'b_ff';'c_f';'d-_g-';'d_g';'e-_g-';'e_a';'f_b-';
'g-_b';'g_cc';'a-_dd-';'a_dd';'b-_ee-';'b_ee';'c_e';'d-_f';'d_g-';'e-_g';'e_g-';'f_a';'g-_b-';'g_b';
'a-_cc';'a_dd-';'b-_dd';'b_ee-';'c_e-';'d-_e';'d_f';'e-_g-';'e_g';'f_g-';'g-_a';'g_b-';'a-_b';'a_cc';
'b-_dd-';'b_dd';'c_d';'d-_e-';'d_e';'e-_f';'e_g-';'f_g';'g-_g-';'g_a';'a-_b-';'a_b';'b-_cc';'b_dd-';
'c_d-';'d-_d';'d_e-';'e-_e';'e_f';'f_g-';'g-_g';'g_g-';'a-_a';'a_b-';'b-_b';'b_cc';'c_c';'d-_d-';'d_d';
'e-_e-';'e_e';'f_f';'g-_g-';'g_g';'a-_a-';'a_a';'b-_b-';'b_b';'c_B';'d-_c';'d_d-';'e-_d';'e_e-';'f_e';
'g-_f';'g_g-';'a-_g';'a_a-';'b-_a';'b_b-';'c_B-';'d-_B';'d_c';'e-_d-';'e_d';'f_e-';'g-_e';'g_f';'a-_g-';
'a_g';'b-_a-';'b_a';'c_A';'d-_B-';'d_B';'e-_c';'e_d-';'f_d';'g-_e-';'g_e';'a-_f';'a_g-';'b-_g';'b_a-';
'c_A-';'d-_A';'d_B-';'e-_B';'e_c';'f_d-';'g-_d';'g_e-';'a-_e';'a_f';'b-_g-';'b_g';'c_G';'d-_A-';'d_A';
'e-_B-';'e_B';'f_c';'g-_d-';'g_d';'a-_e-';'a_e';'b-_f';'b_g-';'c_G-';'d-_G';'d_A-';'e-_A';'e_B-';'f_B';
'g-_c';'g_d-';'a-_d';'a_e-';'b-_e';'b_f';'c_F';'d-_G-';'d_G';'e-_A-';'e_A';'f_B-';'g-_B';'g_c';'a-_d-';
'a_d';'b-_e-';'b_e';'c_E';'d-_F';'d_G-';'e-_G';'e_A-';'f_A';'g-_B-';'g_B';'a-_c';'a_d-';'b-_d';'b_e-';
'c_E-';'d-_E';'d_F';'e-_G-';'e_G';'f_A-';'g-_A';'g_B-';'a-_B';'a_c';'b-_d-';'b_d';'c_D';'d-_E-';'d_E';
'e-_F';'e_G-';'f_G';'g-_A-';'g_A';'a-_B-';'a_B';'b-_c';'b_d-';'c_D-';'d-_D';'d_E-';'e-_E';'e_F';'f_G-';
'g-_G';'g_A-';'a-_A';'a_B-';'b-_B';'b_c';'c_C';'d-_D-';'d_D';'e-_E-';'e_E';'f_F';'g-_G-';'g_G';'a-_A-';
'a_A';'b-_B-';'b_B'}';

%% MATRIX FORMATS

 case 'pcdist2essen'
ref = [0.0464,0.0005,0.0632,0.0027,0.0232,0.0014,0.0001,0.0371,0.0001,0.0030,0.0021,0.0267;
0.0002,0.0001,0.0002,0.0003,0.0000,0.0001,0,0.0000,0.0000,0.0000,0.0000,0.0000;
0.0329,0.0004,0.0301,0.0084,0.0508,0.0138,0.0002,0.0087,0.0000,0.0024,0.0003,0.0052;
0.0029,0.0001,0.0052,0.0034,0.0001,0.0061,0.0000,0.0029,0.0001,0.0000,0.0009,0.0000;
0.0243,0.0001,0.0321,0.0001,0.0346,0.0390,0.0003,0.0379,0.0000,0.0009,0.0000,0.0007;
0.0039,0.0000,0.0083,0.0048,0.0217,0.0172,0.0001,0.0396,0.0005,0.0038,0.0002,0.0005;
0.0002,0,0.0002,0.0000,0.0007,0.0000,0.0004,0.0018,0.0000,0.0003,0,0.0000;
0.0278,0,0.0179,0.0015,0.0331,0.0227,0.0035,0.0640,0.0027,0.0384,0.0018,0.0049;
0.0004,0,0.0000,0.0002,0.0000,0.0004,0.0000,0.0019,0.0005,0.0001,0.0010,0.0001;
0.0091,0.0000,0.0025,0.0000,0.0037,0.0041,0.0004,0.0205,0.0003,0.0120,0.0015,0.0105;
0.0036,0.0000,0.0004,0.0005,0.0000,0.0003,0,0.0016,0.0005,0.0010,0.0017,0.0000;
0.0213,0.0000,0.0062,0.0000,0.0006,0.0016,0.0000,0.0047,0.0000,0.0069,0.0000,0.0044];

	label = {'C','C#','D','D#','E','F','F#','G','G#','A','A#','B'};
	label=cellstr(label')';



 case 'ivdist2essen'
ref = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
0,0,0,0,0,0,0,0,0,0,0,0.0000092712,0.0000076279,0,0,0,0.0000153157,0,0.0000074343,0,...
0,0.0000180196,0,0.0000074667,0;
0,0,0,0,0,0,0,0,0.0000079058,0.0000037732,0.0001505077,0.0000139937,0.0002234427,...
0.0001724990,0.0000510184,0.0000902355,0.0000234737,0.0000826437,0.0000139683,...
0.0000027772,0.0000082986,0.0000067038,0.0000230867,0,0;
0,0,0,0,0,0,0,0,0,0.0004123598,0.0000306979,0.0006773546,0.0003350427,0.0000257986,...
0.0007567306,0.0000680788,0.0004938043,0.0000563566,0,0.0000324944,0,0.0001877623,0,0,0;
0,0,0,0,0,0.0000035355,0,0,0.0001010881,0,0.0005705579,0.0000125236,0.0004882950,...
0.0005904536,0.0001132881,0.0001833802,0,0.0013202379,0,0.0000405279,0.0000951061,0,...
0.0000299491,0,0;
0,0,0,0.0000038637,0,0,0,0.0001070812,0.0000382985,0.0004204581,0.0029195250,...
0.0003062210,0.0028828830,0.0001983468,0.0035733891,0.0015131785,0.0002121388,...
0.0009446541,0.0000098932,0.0006378275,0.0000261363,0.0000416469,0,0,0;
0,0,0,0,0,0,0,0,0.0000131735,0.0000041707,0.0003639914,0.0001487581,0.0002469425,...
0.0003297227,0.0000139716,0.0003174901,0.0000373496,0.0000389211,0.0000661462,...
0.0000112515,0.0000836889,0.0000184985,0.0000789274,0,0;
0,0,0,0,0,0.0001169349,0,0.0001214732,0.0017917648,0.0001111768,0.0050493016,...
0.0001069109,0.0045837773,0.0041307361,0.0018807592,0.0023383484,0.0001686101,...
0.0043545120,0.0000022636,0.0005208662,0.0004422185,0.0000553524,0.0000334490,0,0;
0,0,0.0000145512,0,0.0000542707,0.0000059442,0.0000933308,0.0000573838,0.0000039708,...
0.0071033199,0.0002497861,0.0054727360,0.0037994717,0.0001192331,0.0098360120,...
0.0000251917,0.0026414688,0.0002697959,0.0000417777,0.0001735278,0.0000015508,...
0.0015891243,0,0.0000019153,0;
0,0,0,0.0000466267,0,0.0000403118,0.0000223916,0.0019335110,0.0011969636,0.0009860380,...
0.0146862768,0.0001803156,0.0128841954,0.0077501986,0.0088112827,0.0072302328,...
0.0000049198,0.0048642528,0.0000228299,0.0018149904,0.0005951169,0.0000588735,...
0.0003297952,0,0;
0,0,0.0000063157,0.0000400281,0.0002499587,0.0000853104,0.0000146976,0.0018221580,...
0.0002324463,0.0163173012,0.0522858887,0.0359192182,0.0399263477,0.0003913129,...
0.0311830239,0.0098626763,0.0103872143,0.0063662044,0.0000722018,0.0029947275,...
0.0001118650,0.0028148680,0.0001486133,0.0000124656,0;
0,0.0000019228,0,0.0000587519,0.0000124411,0.0001869256,0.0000746475,0.0000419345,...
0.0032455173,0.0002422377,0.0343219079,0.0002275568,0.0135817989,0.0098516995,...
0.0000354557,0.0066875538,0.0000337092,0.0050476255,0.0000948862,0.0001626706,...
0.0009755755,0.0000026358,0.0008005529,0,0;
0,0.0000036583,0.0001505428,0.0003971793,0.0003879454,0.0030331384,0.0002669420,...
0.0049837104,0.0063555849,0.0094128870,0.0402552623,0.0116330965,0.0631673918,...
0.0106492822,0.0228573646,0.0127406542,0.0054782855,0.0135436642,0.0001947830,...
0.0054080233,0.0007006758,0.0025481064,0.0006649398,0.0000082329,0;
0,0,0.0000660230,0.0000075424,0.0012151010,0.0000365005,0.0013103497,0.0006217705,...
0.0000918872,0.0080009180,0.0000808603,0.0157404016,0.0072946147,0.0004228078,...
0.0219671901,0.0000873926,0.0030233996,0.0001063877,0.0000739812,0.0003552687,0,...
0.0004889259,0,0.0000143530,0;
0,0.0000133900,0.0000713869,0.0002271884,0.0001072458,0.0012142239,0.0000107582,...
0.0025135588,0.0059801533,0.0042274032,0.0244586750,0.0000638890,0.0272522331,...
0.0206500770,0.0250944086,0.0036234907,0.0000581171,0.0052825486,0.0000088689,...
0.0013501691,0.0002268503,0.0000413017,0.0000818392,0,0;
0,0,0.0000549223,0.0001188485,0.0010455527,0.0002971347,0.0004163471,0.0013462233,...
0.0000158561,0.0096024028,0.0033779326,0.0093130967,0.0101619765,0.0003313977,...
0.0058479119,0.0006318788,0.0082625877,0.0004405646,0.0000557793,0.0003711230,0,...
0.0002742732,0,0,0;
0,0.0000009150,0.0001825651,0.0001435473,0,0.0013821225,0.0000597918,0.0004113979,...
0.0037647457,0.0000092178,0.0069883549,0.0000352922,0.0090725819,0.0043670760,...
0.0001897210,0.0006518522,0.0000024293,0.0043124520,0,0.0000971548,0.0000754337,0,...
0.0000038921,0,0;
0,0,0.0000516121,0.0009587975,0.0003163507,0.0018180037,0.0000215882,0.0048351434,...
0.0021033741,0.0033821696,0.0089933980,0.0020470666,0.0199762848,0.0004578666,...
0.0031567407,0.0042390020,0.0002595151,0.0002798573,0,0.0004451544,0.0000130051,...
0.0000204573,0,0,0;
0,0,0,0.0000046208,0.0000090542,0.0000041601,0.0000463247,0.0000038801,0.0000478821,...
0.0000431481,0.0001391065,0.0001621057,0.0001291914,0.0000424923,0.0000110725,...
0.0000823724,0.0000178056,0,0,0,0,0,0,0,0;
0,0.0000147449,0.0000512367,0.0000638978,0.0000090672,0.0010127910,0.0000218692,...
0.0005303030,0.0029706393,0.0006912763,0.0056990240,0.0000781795,0.0040069819,...
0.0008722839,0.0003427719,0.0002071526,0.0000009683,0.0003712849,0,0.0000154821,...
0.0000042888,0,0,0,0;
0,0,0.0000120302,0,0.0000595713,0.0001041030,0.0000078506,0.0001421036,0.0000179706,...
0.0012339583,0.0002740847,0.0011830932,0.0008665278,0.0000167994,0.0003688302,0,...
0.0000301348,0,0,0.0000076562,0,0.0000027581,0,0,0;
0,0,0.0000939731,0.0003292071,0,0.0008288003,0,0.0012108870,0.0010060857,...
0.0002034163,0.0014331615,0.0000035503,0.0029133642,0.0002648763,0.0001889166,...
0.0003883429,0,0.0000616337,0,0.0000353335,0,0,0,0,0;
0,0,0.0000725973,0.0000854068,0.0000010528,0.0002404277,0.0000133297,0.0002242229,...
0.0001088075,0.0000745238,0.0004323090,0.0001282617,0.0010138151,0.0000069721,...
0.0000090604,0.0000470157,0.0000059592,0.0000201762,0,0,0,0,0,0,0;
0,0,0,0,0,0.0000068376,0.0000031474,0,0.0000236557,0,0.0000228939,0.0000095640,...
0.0000158726,0.0000047334,0,0,0,0.0000081107,0,0,0,0,0,0,0;
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];


	label = {'-12','-11','-10','-9','-8','-7','6','-5','-4','-3','-2','-1','+1','+2','+3','+4','+5','+6','+7','+8',...
	'+9','+10','+11','+12'};
	label=cellstr(label')';

 case 'durdist2essen'
ref = [0.0327,0.0001,0.0129,0.0267,0.0037,0.0009,0.0002,0.0000,0;
0.0001,0.0021,0.0003,0.0000,0.0005,0.0000,0.0001,0.0000,0;
0.0256,0.0002,0.3000,0.0000,0.0811,0.0296,0.0062,0.0005,0.0000;
0.0049,0.0001,0.0142,0.0001,0.0059,0.0003,0.0007,0.0000,0;
0.0111,0.0004,0.0943,0.0001,0.1476,0.0033,0.0265,0.0037,0.0005;
0.0021,0.0001,0.0197,0.0000,0.0118,0.0011,0.0012,0.0001,0.0000;
0.0013,0.0001,0.0096,0.0000,0.0297,0.0001,0.0339,0.0010,0.0134;
0.0001,0.0000,0.0007,0,0.0033,0.0000,0.0019,0.0002,0.0003;
0,0.0000,0.0001,0.0000,0.0013,0.0000,0.0140,0.0000,0.0156];
	label = {'1','2','3','4','5','6','7','8','9'}; % Silly names for the durations...
	label=cellstr(label')';


 case 'durdist1essen'
    ref=[0.0765,0.0030,0.4439,0.0265,0.2880,0.0360,0.0890,0.0063,0.0308];
	label = {'1','2','3','4','5','6','7','8','9'}; % These are silly names for the durations....
	label=cellstr(label')';


 case 'kkprofs'

ref = [0.39	0.14	0.21	0.14	0.27	0.25	0.15	0.32	0.15	0.22	0.14	0.18;
0.18	0.39	0.14	0.21	0.14	0.27	0.25	0.15	0.32	0.15	0.22	0.14;
0.14	0.18	0.39	0.14	0.21	0.14	0.27	0.25	0.15	0.32	0.15	0.22;
0.22	0.14	0.18	0.39	0.14	0.21	0.14	0.27	0.25	0.15	0.32	0.15;
0.15	0.22	0.14	0.18	0.39	0.14	0.21	0.14	0.27	0.25	0.15	0.32;
0.32	0.15	0.22	0.14	0.18	0.39	0.14	0.21	0.14	0.27	0.25	0.15;
0.15	0.32	0.15	0.22	0.14	0.18	0.39	0.14	0.21	0.14	0.27	0.25;
0.25	0.15	0.32	0.15	0.22	0.14	0.18	0.39	0.14	0.21	0.14	0.27;
0.27	0.25	0.15	0.32	0.15	0.22	0.14	0.18	0.39	0.14	0.21	0.14;
0.14	0.27	0.25	0.15	0.32	0.15	0.22	0.14	0.18	0.39	0.14	0.21;
0.21	0.14	0.27	0.25	0.15	0.32	0.15	0.22	0.14	0.18	0.39	0.14;
0.14	0.21	0.14	0.27	0.25	0.15	0.32	0.15	0.22	0.14	0.18	0.39;
0.38	0.16	0.21	0.32	0.15	0.21	0.15	0.28	0.24	0.16	0.2	0.19;
0.19	0.38	0.16	0.21	0.32	0.15	0.21	0.15	0.28	0.24	0.16	0.20;
0.2	0.19	0.38	0.16	0.21	0.32	0.15	0.21	0.15	0.28	0.24	0.16;
0.16	0.2	0.19	0.38	0.16	0.21	0.32	0.15	0.21	0.15	0.28	0.24;
0.24	0.16	0.2	0.19	0.38	0.16	0.21	0.32	0.15	0.21	0.15	0.28;
0.28	0.24	0.16	0.2	0.19	0.38	0.16	0.21	0.32	0.15	0.21	0.15;
0.15	0.28	0.24	0.16	0.2	0.19	0.38	0.16	0.21	0.32	0.15	0.21;
0.21	0.15	0.28	0.24	0.16	0.2	0.19	0.38	0.16	0.21	0.32	0.15;
0.15	0.21	0.15	0.28	0.24	0.16	0.2	0.19	0.38	0.16	0.21	0.32;
0.32	0.15	0.21	0.15	0.28	0.24	0.16	0.2	0.19	0.38	0.16	0.21;
0.21	0.32	0.15	0.21	0.15	0.28	0.24	0.16	0.2	0.19	0.38	0.16;
0.16	0.21	0.32	0.15	0.21	0.15	0.28	0.24	0.16	0.2	0.19	0.38];

 case 'kkprofs_t'
 
     tmp = refstat('kkmajt');
    MAJ=[];
    for k = 1:12
        MAJ(k,:) = circshift(tmp,[1,k-1])
    end

    tmp = refstat('kkmint');
    MIN=[];
    for k = 1:12
        MIN(k,:) = circshift(tmp,[1,k-1])
    end
    ref = [MAJ; MIN];

 case 'kkprofs_as'
 
     tmp = refstat('kkmaj_as');
    MAJ=[];
    for k = 1:12
        MAJ(k,:) = circshift(tmp,[1,k-1])
    end

    tmp = refstat('kkmin_as');
    MIN=[];
    for k = 1:12
        MIN(k,:) = circshift(tmp,[1,k-1])
    end
    ref = [MAJ; MIN];
    

 case 'pcdist2classical1'
		ref=zeros(12,12);

		% "All other transitions that fall within minor or major scale (plus F#G and GF#) can be arbitrarily be said to occur 0.5% of time. 
		ref(4,:)=.005;
		ref(9,:)=.005;
		ref(11,:)=.005;
		ref(:,4)=.005;
		ref(:,9)=.005;
		ref(:,11)=.005;
		ref(7,8)=.005;
		ref(8,7)=.005;

		% common transitions
		ref(8,8)=.067;
		ref(1,1)=.053;
		ref(8,1)=.049;
		ref(1,3)=.044;
		ref(1,12)=.032;
		ref(1,8)=.032;
		ref(8,6)=.031;
		ref(5,5)=.030;
		ref(5,3)=.030;
		ref(3,1)=.030;
		ref(8,5)=.029;
		ref(8,10)=.029;
		ref(5,6)=.028;
		ref(5,8)=.026;
		ref(3,5)=.024;
		ref(12,1)=.023; 
		ref(1,5)=.022;
		ref(6,8)=.021;
		ref(6,5)=.021;
		ref(10,8)=.020;
		ref(4,3)=.018;
		ref(5,1)=.016;
		ref(3,4)=.014;
		ref(10,12)=.012;
		ref(12,10)=.011;
		ref(3,3)=.011;
		ref(9,8)=.011;

	label = {'C','C#','D','D#','E','F','F#','G','G#','A','A#','B'};
	label=cellstr(label')';


case 'pcdist1schubert'
	% Knopoff & Hutchinson (1983, p. 95): Appendix Iia, Tonal Frequencies for Pieces in Major Keys
	ref= [3918 244 3690 500 4026 2505 696 4517 496 2288 461 1781];
	ref=ref/(sum(ref));
	label = {'C','C#','D','D#','E','F','F#','G','G#','A','A#','B'};
	label=cellstr(label')';


case 'pcdist2classical2'
	% Frequency of occurrence of melodic intervals
	% Source: Youngblood 1958 (from Krumhansl 1990, p. 136)
	ref = [0	6	111	3	70	4	2	84	5	18	3	66;
	1	0	7	2	1	4	0	2	0	2	1	0;
	72	10	0	14	103	29	0	25	0	20	2	14;
	6	0	9	0	1	8	0	11	1	0	2	1;
	63	3	54	11	0	82	5	44	3	7	0	15;
	18	0	22	0	25	0	4	67	0	19	1	4;
	3	0	2	0	7	0	0	21	0	3	0	1;
	55	0	28	4	59	20	19	0	12	80	2	37;
	5	0	0	2	1	1	0	8	0	8	11	0;
	20	1	22	1	19	11	2	35	10	0	15	52;
	20	0	1	1	9	0	0	2	6	5	0	4;
	93	1	32	0	2	2	2	28	0	28	1	0];
	ref=ref/(sum(sum(ref)));
	label = {'C','C#','D','D#','E','F','F#','G','G#','A','A#','B'};
	label=cellstr(label')';

    
    
 otherwise
  disp('Unknown melodic statistic.')

end
